#ifndef BINARYCHROMOSOME_H_
#define BINARYCHROMOSOME_H_

#include <QBitArray>
#include <QMetaType>

#include "Chromosome.h"

/**
  * Class that represents single chromosome.
  * Contains chromosome bits, fitness and methods to cross over and mutate.
  * @author Łukasz Szybka
  */
class BinaryChromosome : public Chromosome
{
public:
    /**
      * Constructor
      */
    BinaryChromosome();
    /**
      * Constructor
      * @param size Lenght of chromosome
      */
    BinaryChromosome(int size);
    /**
      * Copy constructor
      * @param other BinaryChromosome to copy
      */
    BinaryChromosome(const BinaryChromosome &other);
    /**
      * Destructor
      */
    ~BinaryChromosome();

    BinaryChromosome& operator=(const BinaryChromosome& other);

    void setRandom();
    void crossOver(const Chromosome& partner);
    void mutate(int index);

    bool operator==(const Chromosome& other) const;

    QString toString() const;

    Chromosome* duplicate() const;

    QVariant at(int index) const;

    QVariant data() const;

    int size() const;

protected:

private:
    /**
      * Contains chromosome bits
      */
    QBitArray bitArray;
};

Q_DECLARE_METATYPE(BinaryChromosome);

#endif /*BINARYCHROMOSOME_H_*/
